<template>
    <view class="keepScore">
        <view v-if="!(tablelist && tablelist.length)" class="page_dcenter_null">
            <img class="page_dcenter_null_img" src="../../static/img_null_bookbuilding.png" />
            <view>暂无记录</view>
        </view>
        <div v-else>
            <div class="keep-top">
                <div class="keep_top_li" v-for="(item, index) in itemslist" :key="index">{{item}}</div>
            </div>
            <scroll-view scroll-y class="pages">
                <div class="pagesItm" v-for="(item, index) in tablelist" :key="index">
                    <div class="pagesItm_itm">
                        <div class="pagesItm_itm_center">{{item.beginTime? item.beginTime:'/'}}</div>
                    </div>
                    <div class="pagesItm_itm">
                        <div
                            class="pagesItm_itm_center"
                        >{{(item.week?item.week+'周':'--周')+(item.day||item.day == 0?item.day+'天':'--天')}}</div>
                    </div>
                    <div class="pagesItm_itm">
                        <div
                            class="pagesItm_itm_center"
                        >{{item.period == 2? '中': (item.period == 3 ? '晚':'早') }}</div>
                    </div>
                    <div class="pagesItm_itm">
                        <div class="pagesItm_itm_center">{{item.totcNum? item.totcNum:'/'}}</div>
                    </div>
                </div>
            </scroll-view>
            <div class="tableIcon">
                <img @click="toTable" class="tableIcon_img" src="../../static/btn_quxianguanli.png" />
            </div>
        </div>
    </view>
</template>
<script>
export default {
    data() {
        return {
            tablelist: [],
            itemslist: ["时间", "孕周", "时段", "次数"],
            token:'',
        };
    },
    mounted() {
        // var _this = this;
        // _this.getList();
    },
    onUnload: function () {//如果页面被卸载时被执行
        this.gotoHomePage();
    },
    onLoad(option) {
        var _this = this;
        // console.log(option)
        if (option.token) {
            uni.setStorage({
                //存储到本地
                key: "hospital",
                data: { gatewayAddress: "http://183.11.235.36:25555" },
            });
            uni.setStorage({
                //存储到本地
                key: "token",
                data: { token: option.token },
            });
            _this.token = option.token;
            _this.getList();
        } else {
            _this.getList();
        }
    },
    methods: {
        gotoHomePage(){
           if(this.token){
                window.history.back();
           }
        },
        getList() {
            var data = {
                monitorTypeId: "316255958634606592",
            };
            var _this = this;
            _this.$ajaxs
                .get("/mobile/v1/monitor/getMoveHistory", data)
                .then((res) => {
                    if (res.status == 200) {
                        _this.tablelist = res.content;
                    } else {
                        uni.showToast({
                            title: "请检查网络~",
                            icon: "none",
                        });
                    }
                })
                .catch((err) => reject(err));
        },
        toTable() {
            uni.navigateTo({
                url: "./fetalMovement/fetalMoveRecord",
                animationType: "pop-in",
                animationDuration: 200,
            });
        },
    },
};
</script>
<style scoped lang="scss">
.keepScore {
    height: 100vh;
    padding-top: 44px;
    margin-top: -44px;
    background: #f8f8f8;
    .page_dcenter_null {
        padding-top: 180upx;
        text-align: center;
        .page_dcenter_null_img {
            height: 180upx;
            width: 162upx;
        }
    }
    .keep-top {
        display: -webkit-box;
        display: -webkit-flex;
        display: flex;
        text-align: center;
        background: #f8f8f8;
        font-size: 28upx;
        border-top: 2upx solid #ddd;
        .keep_top_li {
            width: 0;
            padding: 0px 16upx;
            -webkit-box-flex: 1;
            -ms-flex: 1;
            flex: 1;
            align-items: center;
            justify-content: center;
            vertical-align: middle;
            height: 90upx;
            line-height: 90upx;
            color: #666;
        }
    }
    .pages {
        height: calc(100% - 90upx);
        .pagesItm {
            display: -webkit-box;
            display: -webkit-flex;
            display: flex;
            text-align: center;
            background: #fff;
            font-size: 28upx;
            border-bottom: 2upx solid #ddd;
            .pagesItm_itm {
                width: 0;
                padding: 0px 16upx;
                -webkit-box-flex: 1;
                -ms-flex: 1;
                flex: 1;
                align-items: center;
                justify-content: center;
                vertical-align: middle;
                height: 140upx;
                color: #666;
                .pagesItm_itm_center {
                    width: 100%;
                    position: relative;
                    top: 50%;
                    transform: translateY(-50%);
                }
            }
        }
        // .pagesItm {
        //     display: -webkit-box;
        // display: -webkit-flex;
        //   display: flex;
        // text-align: center;
        //   height: 140upx;
        //   line-height: 140upx;
        //   background: rgba(255, 255, 255, 1);
        //   border-bottom: 2upx solid #ddd;
        //   font-size: 28upx;
        //   font-weight: 500;
        //   color: #333;
        // }
        // .pagesItm_itm {
        //     -webkit-box-flex: 1;
        //   -ms-flex: 1;
        //   flex: 1;
        //   align-items: center;
        //   justify-content: center;
        //   vertical-align: middle;
        // }
    }
    .tableIcon {
        width: 118upx;
        height: 118upx;
        position: absolute;
        bottom: 20upx;
        right: 55upx;
        .tableIcon_img {
            width: 100%;
            height: 100%;
        }
    }
}
</style>